//
//  DataLoader.h
//  ClienteHabitueIOS
//
//  Created by Mauro Carreño on 6/1/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>


#define URL_BASE_GENERAL_ARGENTINA  @"http://54.232.94.176:8008"
#define URL_BASE_GENERAL_BOLIVIA    @"http://177.71.178.121:8008"
#define URL_BASE_GENERAL_STAGING    @"http://quilmespdv.mooo.com"


#define TYPE_USER_LIST                   1
#define TYPE_ADD_POINTOFSALE             2
#define TYPE_GET_POINTSOFSALE            3
#define TYPE_ADD_AUDIT                   4
#define TYPE_GET_AUDIT_TYPES             5
#define TYPE_GET_COMMENTS                6

@class DataLoaderConnection;

@interface DataLoader : NSObject{
    
    int remainingParsing;
    NSMutableArray *connections;
    int callType;
    bool isUsingHistory;
    bool isReadingFromHistory;
    NSString* historyFileName;
}

- (id) initWithCaller:(id)caller successSel:(SEL)successTaget failureSel:(SEL) failureTarget;
- (void) parseData:(NSString*)data_string OfType:(int)type andResponseCode:(NSInteger)responseCode andDataLoaderConnection:(DataLoaderConnection*) dataLoaderConnection;
- (void) dataReady:(DataLoaderConnection*) dataLoaderConnection;
- (void) dataNotReady:(DataLoaderConnection*) dataLoaderConnection;
+ (BOOL) checkInternet;
+ (bool) isNull:(id)obj;

- (void) loadUsers;
- (void) loadPointsOfSell:(CLLocation*)location;
- (void) loadAuditTypes;
- (void) postPointOfSell:(NSString*) json;
- (void) postAudit:(NSString*) json;
+ (void) setUrlBaseGeneral:(NSString*)aUrlBaseGeneral;
+ (NSString*) urlBaseGeneral;


@property (nonatomic, unsafe_unretained) SEL successSelector;
@property (nonatomic, unsafe_unretained) SEL failureSelector;
@property (nonatomic, strong) id callerOfSelector;
@property (nonatomic, retain) NSMutableArray *connections;
@property (nonatomic, assign) int callType;
@property (nonatomic, assign) int remainingParsing;
@property (nonatomic, assign) bool isUsingHistory;
@property (nonatomic, assign) bool isReadingFromHistory;
@property (nonatomic, retain) NSString* historyFileName;


@end
